import routes from '../router/routeConfig'
function hasPermission(route,checkedKeys){
    if(route.auth){
        // console.log('arr',checkedKeys);
        return checkedKeys.includes(route.auth);
    }else{
        return true
    }
}

// 接收路由表和用户权限表作为参数
export function getRoutes(routes,checkedKeys){
    var newRoutes = [];
    newRoutes = routes.filter((route)=>{
        if(hasPermission(route,checkedKeys)){
            if(route.children){
                route.children = getRoutes(route.children,checkedKeys)
            }
            return true
        }else{
            return false
        }
    })
    return newRoutes;
}